<?php
include('config.php');
$username=$_POST['username'];
$password=$_POST['password'];
$repeat=$_POST['repassword'];
$mail=$_POST['email'];
if(isset($_POST['reg']))
{
	if($password == $repeat and $password != "" and $mail != "")
	{
		$check=mysql_query("Select * from account where id = '$username'");
		if(mysql_num_rows($check) == 0)
		{
			$check2=mysql_query("Select * from account where email = '$mail'");
			if(mysql_num_rows($check2) == 0)
			{
				mysql_query("INSERT INTO account (id,password,email) VALUES ('$username','$password','$mail')");
				$notice="Đăng kí thành công tài khoản <font color='blue'>$username</font><br /> Click <a href='login.php'>here</a> để đăng nhập";
			}
			
			if(mysql_num_rows($check2) >= 1)
			{
				$notice="Email $mail đã được sử dụng";
			}
		}
		if(mysql_num_rows($check) >= 1)
		{
			$notice="Tài khoản $username đã tồn tại";
		}
	}
	else
	{
		$notice="Thông tin bạn nhập chưa chính xác, đầy đủ $username";
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Đăng ký nhanh</title>
<link href="./reg_files/keyboard.css" rel="stylesheet" type="text/css">
<script src="./reg_files/jquery-core.js" type="text/javascript"></script>
<script src="./reg_files/common.js" type="text/javascript"></script>
<link href="https://img.zing.vn/idzing/theme/default/products/tienthe/css/subpage_trial.css" rel="stylesheet">
<script type="text/javascript" src="./reg_files/jquery.js"></script>
<script type="text/javascript" src="./reg_files/trial_register.js"></script>
<script type="text/javascript" src="./reg_files/keyboard.js"></script>
<script type="text/javascript" src="./reg_files/addKeyboard.js"></script>
<link href="css/styles.css" rel="stylesheet" type="text/css"/>
<!--[if IE 6]> 
<script src="https://img.zing.vn/idzing/theme/default/products/tienthe/js/DD_belatedPNG_0.0.8a.js"></script>
<script language="javascript">
     DD_belatedPNG.fix('.box_popup');
</script>
<![endif]-->
</head>
<body>
<div class="container">
  <div class="header">
    <div class="menu-top">
      <div class="left-menu">
        <ul>
          <li><a href="/">Trang Chủ</a></li>
          <li><a href="#">Hướng Dẫn</a></li>
          <li><a href="#">Nạp Thẻ</a></li>
        </ul>
      </div>
      <div class="right-menu">
        <ul>
          <li><a href="http://diendan.daokiemvotinh.com" target="_blank">Forum</a></li>
          <li><a href="#">Facebook</a></li>
          <li><a href="#">CSKH</a></li>
        </ul>
      </div>
    </div>
    
    <div class="logo-top"><a href="/"><img src="images/logo_130.png" width="130"/></a></div>
    
    <div style="width:470px; display:block; margin:0 auto; padding-top:150px;">
    <div class="box_popup">
      <div class="box_popup_body">
        <div class="box_popup_bt">
          <div class="box_popup_top">
            <div class="box_popup_content">
              <div class="content contentdangky">
                <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0">
                    <tbody>
                  
                  <tr>
                    <td><form action="reg.php" method="post" name="reg" onClick="return validate()">
                        <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                          
                          <tr>
                            <td><table width="100%" border="0" cellpadding="3" cellspacing="3">
                                <tbody>
                                  <tr>
                                    <td style="color: rgb(255, 0, 0);" id="err_form" colspan="3" align="center"></td>
                                  </tr>
                                  <tr>
                                  <tr> <a><font color='red'><?php echo $notice; ?></font></a> </tr>
                                <td valign="top" width="32%" align="left"><span class="title_">Tên đăng nhập</span></td>
                                  <td colspan="2" style="height: 28px;" valign="top" width="70%"><span id="label_sUserName">
                                    <input name="username" id="username" value="" maxlength="24" size="20" type="text">
                                    </span><br>
                                    <span class="org" id="username_err"></span>
                                    <div style="position: relative;">
                                      <div id="suggest_account" class="goiy">
                                        <div id="sub_suggest_account" align="left"></div>
                                      </div>
                                    </div></td>
                                </tr>
                                <tr>
                                  <td valign="top" align="left"><span class="title_">Mật khẩu</span></td>
                                  <td colspan="2" valign="top"><input class="keyboardInput" name="password" id="password" maxlength="32" type="password"></td>
                                </tr>
                                <tr>
                                  <td valign="top" align="left"><span class="title_">Xác nhận mật khẩu</span></td>
                                  <td colspan="2" valign="top"><input class="keyboardInput" name="repassword" id="repassword" maxlength="32" type="password"></td>
                                </tr>
                                <tr>
                                  <td valign="top" align="left"><span class="title_">Email</span></td>
                                  <td colspan="2" valign="top"><input class="keyboardInput" name="email" id="email" maxlength="32" type="text"></td>
                                </tr>
                                <tr>
                                  <td valign="top" align="left"><span class="title_">CMND</span></td>
                                  <td colspan="2" valign="top"><input class="keyboardInput" name="cmnd" id="cmnd" maxlength="16" type="text"></td>
                                </tr>
                                <tr>
                                  <td>&nbsp;</td>
                                  <td colspan="2" align="left"><input value="Đăng ký" name=reg type="submit" class="dangky"></td>
                                </tr>
                                  </tbody>
                                
                              </table></td>
                          </tr>
                            </tbody>
                          
                        </table>
                        <input type="hidden" id="action" name="action" value="register">
                      </form></td>
                  </tr>
                    </tbody>
                  
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    </div>
    
  </div>
  <div class="footer">
    <div class="footer-content">
      <div class="logo-small"><a href="#"><img src="/images/logo.png" height="84" /> </a></div>
      <div class="copyright">© Bản quyền 2013 thuộc về <a href="#">daokiemvotinh.com</a><br/>
        YIM:<a href="">hotrodaokiemvotinh</a> <br/>
        Email: <a href="#">hotro@daokiemvotinh.com</a> </div>
      <div class="phuhop"><a href="#"><img src="/images/phuhop.png" height="66" /></a></div>
    </div>
  </div>
</div>
<script type="text/javascript" src="./reg_files/jquery-1.4.2.min.js"></script> 
<script type="text/javascript" src="./reg_files/inlinekeywords.js"></script> 
<script type="text/javascript" src="./reg_files/pconfig.js"></script>
</body>
</html>